package cn.tedu.csmall.product.mapper;

import cn.tedu.csmall.product.pojo.entity.Brand;
import cn.tedu.csmall.product.pojo.vo.AlbumStandardVO;
import cn.tedu.csmall.product.pojo.vo.BrandListItemVO;
import cn.tedu.csmall.product.pojo.vo.BrandStandardVO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest
public class BrandMapperTets {
    @Autowired
    BrandMapper mapper;
    @Test
    void testInsert(){
        Brand brand=new Brand();
        brand.setName("新的品牌2");
        brand.setSort(86);
        System.out.println("插入数值之前:"+brand);
        int row=mapper.insert(brand);
        System.out.println("插入数值之后:"+brand);
    }
    @Test
    void teatInserts(){
        List<Brand>list=new ArrayList<>();
        Brand brand=new Brand();
        for (int i = 2; i <9 ; i++) {
            brand.setName("新的品牌"+i);
            brand.setSort(90+i);
            list.add(brand);
            System.out.println("插入数值之前:"+brand);
        }
        int inserts = mapper.inserts(list);
    }
    @Test
    void testdeleteById(){
        Long id=5L;
        int row=mapper.deleteById(id);
        System.out.println("row = "+row);
    }
    @Test
    void testdeleteByIds(){
        Long [] id={1L,2L,3L,4L,5L,6L};
        int row=mapper.deleteByIds(id);
    }

  @Test
  void testUpdate(){
        Brand brand=new Brand();
        brand.setId(2L);
        brand.setKeywords("");
        brand.setSales(5);
        int update = mapper.update(brand);
        System.out.println(update);
  }
    @Test
    void a(){
        Long a=6L;
        BrandStandardVO standard= mapper.getStandardVO(a);
        System.out.println(standard);
    }
    @Test
    void testList(){
        List<BrandListItemVO> list = mapper.listBrand();
        for (BrandListItemVO l :list) {
            System.out.println(l);
        }
    }
}
